﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BBS.Bll.Extend
{
    public static class ObjectExtend
    {
        /// <summary>
        /// 将对象转换成int，如果对象转换失败返回-1
        /// </summary>
        /// <param name="str">被转换对象</param>
        /// <returns>转换结果</returns>
        public static int ToInt(this object str)
        {
            int foo = 0;
            if (null!=str && int.TryParse(str.ToString(), out foo))
            {
                return foo;
            }
            return -1;
        }
    }
}
